﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ParadiseShophcm.Control
{
    public partial class WUCChiTietSP : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadChiTiet();
               
            }
        }
        DataProvider dt = new DataProvider();

        public void LoadChiTiet()
        {
            int MaSanPham =int.Parse(Request.QueryString["id"].ToString());
            //Session["MaSanPham"] = MaSanPham.ToString();
            String sql = "SELECT MaSanPham, TenSanPham, ChiTiet, Gia,SanPham.MaTheLoai,TheLoai.TenTheLoai, HinhAnh, NgayDang FROM  SanPham,TheLoai WHERE SanPham.MaTheLoai=TheLoai.MaTheLoai AND (MaSanPham = '"+MaSanPham+"')";
            if (dt.MoKetNoi())
            {
                DTLChiTiet.DataSource = dt.ExecuteQuery(sql,null);
                DTLChiTiet.DataBind();
            }
            String que = "Select * from SanPham Where MaSanPham='"+MaSanPham+"'";
            DataTable tb = dt.ExecuteQuery(que,null);
            if (tb.Rows.Count > 0)
            {
                int MaTheLoai =int.Parse( tb.Rows[0]["MaTheLoai"].ToString());
                String qu = "Select * from SanPham Where MaTheLoai='"+MaTheLoai+"'";

                DTLShowsp.DataSource = dt.ExecuteQuery(qu,null);
                DTLShowsp.DataBind();
                
            }
        }
    }
}